/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainAdminForm.java
 *
 * Created on Apr 5, 2012, 9:31:15 AM
 */
package Admin;

import Constructor.Common;
import Util.DataUtil;
import View.CreateAccountForm;
import View.LoginForm;
import View.MainUserForm;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.sql.Connection;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author Admin
 */
public class MainAdminForm extends javax.swing.JFrame {

    JDesktopPane desktopPane;
    Container container = null;
    JPanel panelBgImg;
    Connection conn = null;
    DataUtil util = new DataUtil();

    /** Creates new form MainAdminForm */
    public MainAdminForm() {
        initComponents();
        LoadForm();
        backgroundImage();
       
    }

    public final void LoadForm() {
        this.setTitle("Quiz Game Show Manager");
        //desktopPane = new JDesktopPane();
        //this.setContentPane(desktopPane);
        lbltilte.setText("Wellcome " + Common._fullName + " (Admin)");
        ImageIcon icon = new ImageIcon(getClass().getResource("/Images/logo.png"));
        Image image = icon.getImage();
        setIconImage(image);
        int width = 1000;
        int height = 650;
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        setBounds(x, y, width, height);
        setResizable(true);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    }

    public final void backgroundImage() {
        container = getContentPane();
        container.setLayout(null);
        ImageIcon img = new ImageIcon(this.getClass().getResource("/Images/background.jpg"));
        panelBgImg = new JPanel() {

            @Override
            public void paintComponent(Graphics g) {
                Image img1 = new ImageIcon(this.getClass().getResource("/Images/background.jpg")).getImage();
                Dimension size = new Dimension(img1.getWidth(null), img1.getHeight(null));
                setPreferredSize(size);
                setMaximumSize(size);
                setMinimumSize(size);
                setSize(size);
                setLayout(null);
                g.drawImage(img1, 0, 0, null);
            }
        };
        container.add(panelBgImg);
        panelBgImg.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());

        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbltilte = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuSystem = new javax.swing.JMenu();
        menuQuestion = new javax.swing.JMenuItem();
        menuViewReport = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuPermision = new javax.swing.JMenu();
        menuMyProfile = new javax.swing.JMenuItem();
        menuchangePassword = new javax.swing.JMenuItem();
        muneAbout = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        lbltilte.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbltilte.setText("WellCome");

        menuSystem.setText("System");
        menuSystem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSystemActionPerformed(evt);
            }
        });

        menuQuestion.setText("Question");
        menuQuestion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuQuestionActionPerformed(evt);
            }
        });
        menuSystem.add(menuQuestion);

        menuViewReport.setText("View Report");
        menuSystem.add(menuViewReport);

        jMenuItem1.setText("Logout");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuSystem.add(jMenuItem1);

        jMenuBar1.add(menuSystem);

        menuPermision.setText("Permision");

        menuMyProfile.setText("My Profile");
        menuMyProfile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuMyProfileActionPerformed(evt);
            }
        });
        menuPermision.add(menuMyProfile);

        menuchangePassword.setText("Change Password");
        menuchangePassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuchangePasswordActionPerformed(evt);
            }
        });
        menuPermision.add(menuchangePassword);

        jMenuBar1.add(menuPermision);

        muneAbout.setText("About");
        jMenuBar1.add(muneAbout);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(322, 322, 322)
                .addComponent(lbltilte, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
                .addGap(329, 329, 329))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbltilte)
                .addContainerGap(604, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuchangePasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuchangePasswordActionPerformed
        // TODO add your handling code here:
        ChangePasswordForm frm = new ChangePasswordForm(this, true);
        frm.setVisible(true);
    }//GEN-LAST:event_menuchangePasswordActionPerformed

    private void menuSystemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSystemActionPerformed
        // TODO add your handling code here:
        
}//GEN-LAST:event_menuSystemActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        if (JOptionPane.showConfirmDialog(this, "Do you really want to logout? ") == JOptionPane.YES_OPTION) {
            MainUserForm fm = new MainUserForm();
            this.dispose();
            fm.setVisible(true);
        }
}//GEN-LAST:event_jMenuItem1ActionPerformed

    private void menuQuestionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuQuestionActionPerformed
        // TODO add your handling code here:
        ManagerQuestion frm = new ManagerQuestion(this, true);
        //desktopPane.add(frm);
        frm.setVisible(true);
    }//GEN-LAST:event_menuQuestionActionPerformed

    private void menuMyProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuMyProfileActionPerformed
        // TODO add your handling code here:
        MyProfileForm frm= new MyProfileForm();
        frm.setVisible(true);
    }//GEN-LAST:event_menuMyProfileActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainAdminForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JLabel lbltilte;
    private javax.swing.JMenuItem menuMyProfile;
    private javax.swing.JMenu menuPermision;
    private javax.swing.JMenuItem menuQuestion;
    private javax.swing.JMenu menuSystem;
    private javax.swing.JMenuItem menuViewReport;
    private javax.swing.JMenuItem menuchangePassword;
    private javax.swing.JMenu muneAbout;
    // End of variables declaration//GEN-END:variables
}
